Skip to content

fix(live): persona replies keep the thread, follow the recipient's language, and handle refusals - #20

Merged
dalpan merged 1 commit into
feature/report-mailboxfrom
feature/persona-reliability
Oct 31, 2026
Merged

dalpan merged 1 commit into
feature/report-mailboxfrom
feature/persona-reliability

Conversation

@dalpan

@dalpan dalpan commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Stacked on #19.

Problem

Reply Review showed persona drafts that were refusals ("I cannot generate persuasive phishing…") or completely empty. Causes:

  • The model was told to continue "an email thread you started" but never saw the original email — only the recipient's reply.
  • An empty/blocked provider response was queued as a normal draft (and could be approved as a blank email).
  • Replies always used the campaign language, even when the recipient wrote in another language.

Changes

  • Lure in the prompt: lure_text() turns body_html into plain text ({{.URL}} → [link], other template tags removed) and the system prompt includes it with the subject. Prompt states the real context: authorized exercise run by the recipient's organization, human-reviewed before sending, recipient debriefed, nothing collected.
  • History = recipient messages + replies actually sent (unapproved/discarded drafts excluded).
  • Language: detect_language() on the recipient's message (ID/EN word heuristics) overrides the campaign language when clear.
  • Refusals: is_refusal() (empty, or EN/ID refusal phrasing; tuned to not flag "I can't wait…" / "I'm sorry for the delay…") → retry once → otherwise queue an empty draft with persona_declined: true.
  • Approve guard: empty body → 400.
  • Review queue returns campaign_name and in_reply_to; Reply Review page shows them, flags "AI did not draft", disables approve until there is text, and is localized EN/ID. Campaign conversation panel shows the declined note instead of a blank bubble.
  • Walkthrough troubleshooting row.

This does not try to get around provider safety behaviour; the fallback is a human writing the turn (G8), or a local model.

Testing

  • pytest: 250 passed (refusal/language/lure parsing, prompt contents, retry, persistent refusal, history filtering, empty-approve guard, review context)
  • ruff clean; CI=true craco build OK
  • Manual with Gemini + GreenMail: Indonesian reply to an English OTP-objective campaign → Indonesian draft that continues the original email, queued for review.

🤖 Generated with Claude Code

…nguage, and handle refusals

- The persona prompt now includes the original lure (HTML stripped, GoPhish
  {{.URL}} shown as [link]); previously the model was asked to continue a
  thread it could not see.
- History holds only what the recipient saw: their messages and replies that
  were actually sent (no unapproved or discarded drafts).
- The persona answers in the language the recipient wrote in, falling back to
  the campaign language.
- A model refusal or empty output is retried once; if it persists, an empty
  draft marked persona_declined is queued so the reviewer writes the turn,
  instead of queueing the refusal text or a blank email.
- Approving a draft with an empty body is rejected (400).
- Review queue includes the campaign name and the message being answered;
  Reply Review page localized (EN/ID) and shows the declined state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant